package com.demo.newarchitecture.rn;

import androidx.annotation.NonNull;

import com.demo.newarchitecture.modules.ToastModule;
import com.demo.newarchitecture.viewManager.infoViewGroupManager;
import com.demo.newarchitecture.viewManager.infoViewManager;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.List;

// 注册中心
public class DemoPackage implements ReactPackage {
    @NonNull
    @Override
    public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext context) {
        List<NativeModule> modules = new ArrayList<>();
        modules.add(new AppModule桥接原生(context));

        modules.add(new ToastModule(context)); // 来自  https://reactnative.cn/docs/native-modules-android#toast-%E6%A8%A1%E5%9D%97
        return modules;
    }

    @NonNull
    @Override
    public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext context) {
        List<ViewManager> viewManagers = new ArrayList<>(); // 用来桥接原生页面
        viewManagers.add(new infoViewManager());


        viewManagers.add(new infoViewGroupManager());
        return viewManagers;  // 暂时返回空数组就行了（用到可以增加）
    }
}
